package com.gzh.check1.controller;

import com.gzh.check1.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description TODO
 * @Author gzh
 * @Date 2020/10/24 22:58
 */
@Controller
@Api(tags = "UmsMemberCouponController", description = "用户优惠券管理")
@RequestMapping("/member/coupon")
public class UmsMemberCouponController {

    /**
     * 这里拿用户领取优惠券的代码为例，我们先对比下改进前后的代码，首先看Controller层代码。改进后
     * 只要Service中的方法执行成功就表示领取优惠券成功，因为领取不成功的话会直接抛出ApiException
     * 从而返回错误信息；
     */

    //改进前
//    @ApiOperation("领取指定优惠券")
//    @RequestMapping(value = "/add/{couponId}", method = RequestMethod.POST)
//    @ResponseBody
//    public CommonResult add(@PathVariable Long couponId) {
////        return memberCouponService.add(couponId);
//        return CommonResult.success(null,"领取成功");
//    }

    //改进后
    @ApiOperation("领取指定优惠券")
    @RequestMapping(value = "/add/{couponId}", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult add(@PathVariable Long couponId) {
        //memberCouponService.add(couponId);
        return CommonResult.success(null,"领取成功");
    }

}
